


const mongoose=require("mongoose");
const hostname="0.0.0.0";
const port=27017;
const dbname="wh1915";
const CONN_DB_STR=`mongodb://${hostname}:${port}/${dbname}`;
//连接数据库
mongoose.connect(CONN_DB_STR,{
    useNewUrlParser:true,
    useUnifiedTopology:true,
});
//连接对象
const connection=mongoose.connection;
connection.on("connected",()=>{
    console.log("连接数据库成功")
})
connection.on("error",(err)=>{
    console.log("连接数据库失败"+err);
})
module.exports=connection;